﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		event.setArg("pageTitle", "网上成绩录入 - 补考成绩录入情况");
		
		termId = event.getArg("TID", event.getArg("TermID"));
		depId = sessionAdvice.getUserProp("teacherDepartment");
		
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		targetArgs = structNew();
		structInsert(targetArgs, "TID", termId, true);
		structInsert(targetArgs, "DepID", depId, true);
		
		currentTab = event.getArg("TabID", "labTask");
		
		/* 任课单位信息 */
		sql = "SELECT
					i.institute_id,i.institute_name
				FROM
					t_institute i
				WHERE
					i.institute_id = :depID ";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "depID", value=depID, cfsqltype="cf_sql_varchar");
		rs_departmentEntity = queryObj.execute(sql = sql).getResult();

		/* 读取已激活成绩任务提交状况 */
		sql = "	SELECT
					rp.task_id,rp.task_type,rp.task_prog,rp.mark_done,rp.mark_need,
					c.course_name,c.course_credit,
					c.course_code,
					rp.cidx,
					i.institute_short,
					c.mark_mode
				FROM
					t_resitplan rp
					INNER JOIN t_course c ON c.cid = rp.cid
					INNER JOIN t_institute i ON i.institute_id = c.institute_id
				WHERE
					i.institute_id = :depId 
					AND
					rp.term_id = :termId 
				ORDER BY
					rp.task_prog DESC,
					c.course_name,rp.cidx";

		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "depId", value=depId, cfsqltype="cf_sql_varchar");
		queryObj.addParam(name = "termId", value=termId, cfsqltype="cf_sql_char");
		rs_task = queryObj.execute(sql = sql).getResult();

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学运行安排</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput>学期成绩提交情况
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
			
				<div class="UItab">
					<div class="tabLables">
						<cfif rs_task.recordCount>
							<span <cfif currentTab eq "labTask">class="active"</cfif> id="labTask" tabTarget="Task">补考成绩提交状态</span>
						</cfif>
					</div>
				</div>
			
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
				
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
				
					});
					// -->
					//]]>
				</script>
			
				<div id="Task" class="tabContent">
					
					<cfif rs_departmentEntity.recordCount>
						<cfset structInsert(targetArgs, "DepID", rs_departmentEntity.institute_id, true) />
						<div class="noticeBlock">
							<h3><cfoutput>#rs_departmentEntity.institute_name#</cfoutput></h3>
							<p>
								<span class="img icon16x16 message"></span>
								<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 
								已网上成绩录入课程教学任务 <em><cfoutput>#rs_task.recordCount#</cfoutput></em> 个
								.
							</p>
							<hr/>
						</div>
					</cfif>
					
					<cfif rs_task.recordCount>

						<table class="UIEditable">
							<thead>
								<tr>
									<td width="30"></td>
									<td>课程</td>
									<td width="90">主讲教师</td>
									<td width="40">学分</td>
									<td width="50">部门</td>
									<td width="60">提交进度</td>
									<td width="60">计分模式</td>
									<td width="60">状态</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
								<cfset row = 0 />
                                <cfloop query="rs_task">
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_task.task_id, true) />
									<cfset structInsert(targetArgs, "TT", rs_task.task_type, true) />
									<!--- 反向读取任务的主讲教师 --->
                                    <cfswitch expression="#rs_task.task_type#">
                                    	<cfcase value="P">
                                        	<cfscript>
                                            	sql = "	SELECT
															tch.tch_name
														FROM
															t_task tsk
															INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
														WHERE
															tsk.tsk_id = :taskId ";
												queryObj = new Query(datasource = application.dnsSlave);
												queryObj.addParam(name = "taskId", value=rs_task.task_id, cfsqltype="cf_sql_varchar");
												rs_taskEntity = queryObj.execute(sql = sql).getResult();
                                            </cfscript>
                                        </cfcase>
                                        <cfcase value="C">
                                        	<cfscript>
                                            	sql = "	SELECT
															tch.tch_name
														FROM
															t_common_task tsk
															INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
														WHERE
															tsk.tsk_id = :taskId ";
												queryObj = new Query(datasource = application.dnsSlave);
												queryObj.addParam(name = "taskId", value=rs_task.task_id, cfsqltype="cf_sql_varchar");
												rs_taskEntity = queryObj.execute(sql = sql).getResult();
                                            </cfscript>
                                        </cfcase>
                                        <cfcase value="R">
                                        	<cfscript>
                                            	sql = "	SELECT
															tch.tch_name
														FROM
															t_reopen_task tsk
															INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
														WHERE
															tsk.tsk_id = :taskId ";
												queryObj = new Query(datasource = application.dnsSlave);
												queryObj.addParam(name = "taskId", value=rs_task.task_id, cfsqltype="cf_sql_varchar");
												rs_taskEntity = queryObj.execute(sql = sql).getResult();
                                            </cfscript>
                                        </cfcase>
                                        <cfcase value="T">
                                        	<cfscript>
                                            	sql = "	SELECT
															tch.tch_name
														FROM
															t_sport_task tsk
															INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
														WHERE
															tsk.tsk_id = :taskId ";
												queryObj = new Query(datasource = application.dnsSlave);
												queryObj.addParam(name = "taskId", value=rs_task.task_id, cfsqltype="cf_sql_varchar");
												rs_taskEntity = queryObj.execute(sql = sql).getResult();
                                            </cfscript>
                                        </cfcase>
                                    </cfswitch>
									<tr class="editRows" rowid="<cfoutput>#rs_task.task_id#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><cfoutput>#rs_task.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_task.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_taskEntity.tch_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#numberFormat(rs_task.course_credit, '_.__')#</cfoutput></span></td>
										<td><cfoutput>#rs_task.institute_short#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_task.mark_done#</cfoutput> / <cfoutput>#rs_task.mark_need#</cfoutput></span></td>
										<td align="center"><cfoutput>#dictAdvice.getMarkModeName( rs_task.mark_mode )#</cfoutput></td>
										<td class="TaskProgress<cfoutput>#rs_task.task_prog#</cfoutput>"><cfoutput>#dictAdvice.getTaskMarkStat( rs_task.task_prog )#</cfoutput></td>
										<td>
											<cfif rs_task.task_prog eq "3">
												<a target="_blank" title="打印成绩单" href="<cfoutput>#buildURL('taskMarkResitPrint', targetArgs)#</cfoutput>" class="stat print"></a>
											</cfif>
										</td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					
					</cfif>
					
				</div>

			</div>
		</li>
	</ul>
</div>
			
			
